package com.jx.controller;

import java.io.IOException;
import java.io.PrintWriter;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.jx.model.Goods;
import com.jx.service.GoodsService;
import com.jx.servicrimpl.GoodsServiceImpl;

import net.sf.json.JSONObject;
/**
 * 修改一下配送信息表
 * @author 鄢泽然
 *
 */
public class UpdateGoodsController extends HttpServlet {
	GoodsService gs = new GoodsServiceImpl();
@Override
protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
	// TODO Auto-generated method stub
	doPost(req, resp);
}
@Override
	protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
		// TODO Auto-generated method stub
	req.setCharacterEncoding("utf8");
	resp.setCharacterEncoding("utf8");
	int  oid = Integer.parseInt(req.getParameter("oid"));
	String gname =req.getParameter("gname"); 
	String gtime = req.getParameter("gtime");
	String gstate = req.getParameter("gstate");
	String gaddress = req.getParameter("gaddress");
	Goods g = new Goods();
	g.setOid(oid);
	g.setGname(gname);
	g.setGtime(gtime);
	g.setGstate(gstate);
	g.setGaddress(gaddress);
	JSONObject gg = new JSONObject();
	int i = gs.updateGoods(g);
	PrintWriter pw = resp.getWriter();
	if(i == 1){
		gg.put("msg", "success");
	}
	else {
		gg.put("msg", "fail");
	}
	pw.write(gg.toString());
	}

}
